/*
 * @Author: your name
 * @Date: 2021-09-06 09:51:03
 * @LastEditTime: 2022-04-20 22:47:44
 * @LastEditors: ke.xue
 * @Description: In User Settings Edit
 * @FilePath: \product-display\src\store\index.js
 */
/*
 * @Author: your name
 * @Date: 2021-04-22 11:17:28
 * @LastEditTime: 2021-09-03 17:26:35
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \cip-client-h5\src\store\index.js
 */

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    bannerList: [],
    indexList: [],
    typeTree: localStorage.getItem('typeTree') ? JSON.parse(localStorage.getItem('typeTree')) : [],
    typeObj: localStorage.getItem('typeObj') ? JSON.parse(localStorage.getItem('typeObj')) : [],
    token: '0ffd7322-bae3-4671-a71d-e976e39cab25',
    mapInit: false
  },
  mutations: {
    setBannerList (state, bannerList) {
      state.bannerList = bannerList
    },
    setIndexList (state, indexList) {
      state.indexList = indexList
    },
    setTypeObj (state, typeObj) {
      localStorage.setItem('typeObj', JSON.stringify(typeObj))
      state.typeObj = typeObj
    },
    setTypeTree (state, typeTree) {
      localStorage.setItem('typeTree', JSON.stringify(typeTree))
      state.typeTree = typeTree
    },
    setToken (state, token) {
      state.token = token
    },
    setMapInit (state, mapInit) {
      state.mapInit = mapInit
      console.log('setMapInit')
    }
  },
  modules: {},
  getters: {
    bannerList: state => state.bannerList,
    token: state => state.token,
    mapInit: state => state.mapInit,
    typeObj: state => state.typeObj,
    typeTree: state => state.typeTree,
    indexList: state => state.indexList
  }
})
